﻿#!/usr/bin/python
# -*- encoding: utf-8 -*-
'''
@File    : DemoMenuFunnyWidget.py
@Desc    : 
@Version : 1.0
@Author  : echohelper 
@Email   : echohelper@qq.com
@WebSite : www.github.com/echohelper
@Time    : 2021/09/24 09:20:06
'''
# Start typing your code from here

import os
# import win32api

from PyQt5 import QtCore, QtGui, QtWidgets

from module.string.string_find import string_find
from module.demo.Ui_DemoMenuFunnyWidget import Ui_Form


class DemoMenuFunnyWidget(QtWidgets.QWidget):
    
    def __init__(self):
        super().__init__()
        self.ui = Ui_Form()
        self.ui.setupUi(self)

    def onBtnSelect(self, checked:bool):
        filePath, __ = QtWidgets.QFileDialog.getOpenFileName(None, 'Select File', '.', 'Python Files(*.py);;All Files(*.*)', 'Python File(*.py)')
        self.ui.lineEdit.setText(filePath)

    def onBtnRun(self, checked:bool):
        filePath = self.ui.lineEdit.text()
        if QtCore.QFile.exists(filePath):
            os.system(filePath)
        else:
            QtWidgets.QMessageBox(None, 'Prompt', 'file isn`t exist.')

    def onBtnShutdown(self, checked:bool):
        os.system('shutdown -s -t 120')
    
    def onBtnUnshutdown(self, checked:bool):
        os.system('shutdown -a')

    def onBtnTest1(self, checked:bool):
        filePath = os.getcwd()
        scriptPath = filePath + '/module/funny/DesktopPet/startup.vbs'
        # win32api.ShellExecute(0, 'open', scriptPath, '','',0)
        print(scriptPath)

    def onBtnTest2(self, checked:bool):
        print('222222')
        result = string_find().getString('UuUuU')
        self.ui.btnTest_2.setText(result)

    def onBtnTest3(self, checked:bool):
        print('333333')

    def onBtnTest4(self, checked:bool):
        print('4444444')

    def onBtnTest5(self, checked:bool):
        print('5555555')
